package 
{
    import com.vcar.LDiceClient.command.AppCreatedCommand;
    import com.vcar.LDiceClient.command.ChangeModuleCommand;
    import com.vcar.LDiceClient.command.HotKeyCommand;
    import com.vcar.LDiceClient.command.SocketDataCommand;
    import com.vcar.LDiceClient.command.StartUpCommand;
    import com.vcar.LDiceClient.config.GlobalEventName;
    import com.vcar.LDiceClient.config.ProxyNames;
    import com.vcar.LDiceClient.dataproxy.DateProxy;
    import com.vcar.LDiceClient.dataproxy.RequestMessage;
    import com.vcar.LDiceClient.dataproxy.SocketProxy;
    import com.vcar.LDiceClient.dataproxy.user.UserProxy;
    import com.vcar.LDiceClient.dataproxy.user.UserVO;
    
    import org.puremvc.as3.patterns.facade.Facade;
    

    /**
     * 整个webgame的界面
     * @author rhj
     * <p>
     * 这个界面的接口包括
     * puremvc的常用接口
     * 系统manager类的一些常用接口
     * </p>
     */
    public class ApplicationFacade extends Facade
    {
        public function ApplicationFacade()
        {
            super();
        }

        public static function getInstance():ApplicationFacade
        {
            if(instance==null) instance=new ApplicationFacade();
            return instance as ApplicationFacade;
        }

        /**
         *初始化所有的命令监听
         */        
        override protected function initializeController():void
        {
            super.initializeController()
			registerCommand(GlobalEventName.SYS_INIT_START,StartUpCommand);
			registerCommand(GlobalEventName.APP_CREATE_COMPLETE,AppCreatedCommand);
			registerCommand(GlobalEventName.MODULE_CHANGE,ChangeModuleCommand);
			registerCommand(GlobalEventName.SOCKET_DATA_RECV,SocketDataCommand);
			registerCommand(GlobalEventName.STAGE_HOTKEY_PRESS,HotKeyCommand);
        }
		
		/**
		 * 替代系统的new Date() 
		 */		
		public function getDate():Date
		{
			var p:DateProxy=retrieveProxy(ProxyNames.DateProxy) as DateProxy;
			return p.getDate();
		}
		
		/**
		 * 发送请求到socket 
		 */		
		public function send(param:RequestMessage,succFun:Function=null,capture:Boolean=false):void
		{
			var proxy:SocketProxy = retrieveProxy(ProxyNames.SocketProxy) as SocketProxy;
			proxy.send(param,succFun,capture);
		}
		
		/**
		 * 返回当前玩家 
		 */		
		public function getCurrentUser():UserVO
		{
			var p:UserProxy = retrieveProxy(ProxyNames.UserProxy) as UserProxy;
			return p.currentUserVO
		}

 
    }
}

